package mysql

import "gorm.io/gorm"

type Users struct {
	gorm.Model
	Mobile   string `gorm:"type:char(11);not null;comment:'手机号'"`
	Password string `gorm:"type:char(32);not null;comment:'密码'"`
	Status   int8   `gorm:"type:tinyint;default1;comment:状态:1正常2冻结"`
}
type RealName struct {
	gorm.Model
	UserId   int64  `gorm:"type:int(11);not null;comment:'用户ID'"`
	RealName string `gorm:"type:varchar(20);not null;comment:'姓名'"`
	IDCard   string `gorm:"type:char(18);not null;comment:'身份证号码'"`
}

func (u *Users) GetInfoMobile(mobile string) error {
	//return Db.Where("mobile = ?", mobile).Limit(1).Find(&u).Error
	return Db.Where("mobile = ?", mobile).Limit(1).Find(&u).Error
}
func (u *Users) GetCreates() error {
	return Db.Create(&u).Error
}
func (r *RealName) GetInfoRealName(userId int, idCard string) error {
	return Db.Where("id_card = ? or user_id = ?", userId, idCard).Limit(1).Find(&r).Error
}
func (r *RealName) Creates() error {
	return Db.Create(&r).Error
}
